﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Yunwei.BizLogic;
using Yunwei.Domain.Models;
using Yunwei.IBizLogic;

namespace Yunwei.Web.Areas.Admin.Controllers
{
    public class FoodController : Controller
    {
        IFoodService foodService;

        public FoodController()
        {
            foodService = new FoodService();
        }

        // GET: Admin/Food
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult List()
        {
            return View();
        }

        /// <summary>
        /// 文章列表Json【注意权限问题，普通人员是否可以访问？】
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="input">录入</param>
        /// <param name="category_Id">栏目</param>
        /// <param name="fromDate">日期起</param>
        /// <param name="toDate">日期止</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页记录</param>
        /// <returns></returns>
        public ActionResult JsonList(string title, int restaurant_Id, Nullable<int> category_Id, int chef, Nullable<DateTime> fromDate, Nullable<DateTime> toDate, int pageIndex = 1, int pageSize = 20)
        {
            if (category_Id == null) category_Id = 0;
            int _total;
            var _rows = foodService.FindPageList(out _total, pageIndex, pageSize, title, restaurant_Id, (int)category_Id, chef, fromDate, toDate, 0).Select(
                cm => new Food()
                {

                });

            List<Food> cms = _rows.ToList();
            return Json(new { total = _total, rows = _rows.ToList() });
        }


        public ActionResult Add()
        {
            return View();
        }
    }
}